package com.dxt.controller;

import com.dxt.pojo.User;
import com.dxt.service.DeliveryService;
import com.dxt.service.DeliveryServiceImpl;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.SneakyThrows;

import java.io.IOException;

/**
 * ClassName: DeliveryAddController
 * Package: com.dxt.controller
 * Description:
 *
 * @Author 段鑫涛
 * @Create 2025/3/31 11:46
 * @Version 1.0
 */
@WebServlet("/delivery/addDelivery")
public class DeliveryAddController extends HttpServlet {
    private DeliveryService deliveryService = new DeliveryServiceImpl();
    @SneakyThrows
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String deliveryName = req.getParameter("delivery_name");
        String companyId = req.getParameter("company_id");
        String phone = req.getParameter("phone");
        String address = req.getParameter("address");
        String sendTime = req.getParameter("send_time");
        String state = req.getParameter("state");
        User user = (User)req.getSession().getAttribute("user");

        deliveryService.addDeliveryByUserId(deliveryName,user.getId(),companyId,phone,address,sendTime,state);

        resp.sendRedirect("/delivery/getList");

    }
}
